const Koa = require('koa');
const cors = require('@koa/cors');
const serve = require('koa-static');
const app = new Koa();
const bodyParser = require('koa-bodyparser'); // 处理post请求，把 koa2 上下文的表单数据解析到 ctx.request.body 中
const db = require('./plugins/db');
const path = require('path');
const routers = require('./routes/index');

app.use(cors());
app.use(bodyParser());
app.use(serve('.'));

//  初始化路由中间件
app.use(routers.routes()).use(routers.allowedMethods());

app.listen(3000);